package cn.mysocketnet.a08test2;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.Socket;

public class Client {
    public static void main(String[] args) throws IOException {
        // 创建客户端对象
        Socket client = new Socket("127.0.0.1", 10000);
        // 启动客户端
        OutputStream os = client.getOutputStream();
        os.write("diao mao 服务器".getBytes());
        client.shutdownOutput();

        InputStream inputStream = client.getInputStream();
        InputStreamReader reader = new InputStreamReader(inputStream);
        int len;
        char[] chars = new char[1024];
        while ((len=reader.read(chars))!=-1){
            System.out.println(new String(chars,0,len));
        }
        client.close();
    }
}
